<?php
namespace app\zhonghang\controller;
use think\Controller;
use think\Request;
use think\Db;
use think\Session;
use think\Cache;

require_once (APP_PATH . 'api/RewardApi.php');
class Spec extends Base
{
    public function _initialize()
    {
        parent::_initialize();

    }

    /*
     *商品规格和库存
     **/
    public function guige(){
        $where['goods_id']=input('goods_id');
        $list=DB::name('Goods_stock')->where($where)->select();
        if($list){
            $data['info']='该商品所有规格和库存';
            $data['status']='1';
            $data['data']=$list;
            return json($data);
        }else{
            $data['info']='暂无数据';
            $data['status']='0';
            $data['data']=array();
            return json($data);
        }
    }

    /*
     *选中规格返回价格
     **/
    public function xuanzhong(){
        $where['color']=input('color');
        $where['label']=input('chima');
        $where['goods_id']=input('goods_id');
        $list=DB::name('Goods_stock')->where($where)->find();
        if($list){
            $data['info']='选中规格的价格';
            $data['status']='1';
            $data['data']=$list;
            return json($data);
        }else{
            $data['info']='暂无数据';
            $data['status']='0';
            $data['data']=array();
            return json($data);
        }
    }



}